<%--
  Created by IntelliJ IDEA.
  User: ymwm9
  Date: 2024/4/5
  Time: 22:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"	/>
  <title>贵美商城</title>
  <link rel="stylesheet"	type="text/css"	href="css/global.css"	/>
  <link rel="stylesheet"	type="text/css"	href="css/layout.css"	/>
  <script type="text/JavaScript">
    var strHome = 'http://www.gmgw.com';
    function addFav(){
      switch(getNav()){
        case 1:
          window.external.addFavorite(strHome,'贵美商城');
          break;
        case 2:
          window.sidebar.addPanel('贵美商城',strHome,'');
          break;
        case 0:
          alert("加入收藏失败");
          break;
      }
      function getNav(){
        if(navigator.userAgent.indexOf("MSIE")!=-1)    return 1;
        if(navigator.userAgent.indexOf("Firefox")!=-1) return 2;
        return 0;
      }
    }
    function setHome(oThis){
      oThis.style.behavior='url(#default#homepage)';
      oThis.setHomePage(strHome);
      return false;
    }
    function showTime() {
      var date = new Date();
      var year = date.getFullYear();
      var month = (date.getMonth() + 1 < 10 ? "0" : "") + (date.getMonth() + 1); // getMonth()返回的是0-11，所以需要+1
      var day = (date.getDate() < 10 ? "0" : "") + date.getDate();
      var hours = (date.getHours() < 10 ? "0" : "") + date.getHours();
      var minutes = (date.getMinutes() < 10 ? "0" : "") + date.getMinutes();
      var seconds = (date.getSeconds() < 10 ? "0" : "") + date.getSeconds();

      // 格式化时间
      var fullTime = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;

      // 显示在#currentTime元素中
      document.getElementById("currentTime").textContent = fullTime;
    }

    // 页面加载完成后调用showTime函数，以显示当前时间
    window.onload = showTime;

    // 如果需要实时更新时间，可以设置一个定时器
    setInterval(showTime, 1000); // 每秒更新一次时间

    // 页面加载完成后调用showTime函数，以显示当前时间



  </script>
</head>
<body>
<div id="header">
  <div id="logo"></div>
  <div class="menu">
    <ul>
      <li class="pic pic1"></li>
      <li class="txt"><a href="http://localhost:8080/mall/buyController?action=findAll" target="_parent">购物车</a></li>
      <li class="pic pic2"></li>
      <li class="txt"><a href="help.jsp" target="_parent">帮助中心</a></li>
      <li class="pic pic3"></li>
      <li class="txt"><a href="JavaScript:void(0);" onclick="addFav();">加入收藏</a></li>
      <li class="pic pic4"></li>
      <li class="txt"><a href="JavaScript:void(0);" onclick="setHome(this);">设为首页</a></li>


      <c:if test="${empty sessionScope.username}">
        <li class="pic btn txt"><a href="login.jsp" target="_parent">登录</a></li>
        <li class="pic btn txt"><a href="register.jsp" target="_parent">注册</a></li>
      </c:if>
      <c:if test="${not empty sessionScope.username}">
        <li class="pic btn txt">${sessionScope.username}</li>
      </c:if>

    </ul>
  </div> <!--menu	end-->
  <div class="f_r w62p">
    <ul>
      <c:if test="${empty sessionScope.username}">
        <li class="txt hello">你好，欢迎访问贵美商城！
          <span id="currentTime"></span>
        </li>
      </c:if>
      <c:if test="${not empty sessionScope.username}">
        <li class="txt hello">${sessionScope.username}，欢迎访问贵美商城！
          <span id="currentTime"></span>
        </li>
      </c:if>

    </ul>
  </div>
  <div class="nav f_l w100p">
    <ul id="c_ul">
     <li><a href="index.jsp" target="_parent">&nbsp;首&nbsp;&nbsp;&nbsp;页&nbsp;</a></li>


      <c:forEach items="${categorys}" var="category" varStatus="s">
          <li><a href="http://localhost:8080/mall/category?action=categoryshow&categoryId=${category.cid}" target="_parent">${category.cname}</a></li>
      </c:forEach>

-      <li><a href="help.jsp" target="_parent">帮助中心</a></li>
      <li><a href="help.jsp" target="_parent">免费开店</a></li>
      <li><a href="help.jsp" target="_parent">全球咨询</a></li>
    </ul>
  </div>	<!--nav	end-->
</div> <!--header	end-->
</body>
</html>
